package test.myorm.core;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.sql.DataSource;

import test.myorm.chain.Interceptor;

public class Configuration {
	
	private DataSource dataSource;
	private List<Interceptor> interceptors = new ArrayList<>();
	private Map<String, Sql> sqlMap = new HashMap<>();
	private Map<String, ResultMap> mapResultMap = new HashMap<>();
	
	private Map<String, Object> mapperProxyMap = new HashMap<>();
	
	public DataSource getDataSource() {
		return dataSource;
	}

	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}

	public Map<String, Sql> getSqlMap() {
		return sqlMap;
	}

	public void setSqlMap(Map<String, Sql> sqlMap) {
		this.sqlMap = sqlMap;
	}
	
	public void addSql(String key, Sql sql) {
		this.sqlMap.put(key, sql);
	}

	public Map<String, ResultMap> getMapResultMap() {
		return mapResultMap;
	}
	
	public ResultMap getResultMap(String key) {
		return mapResultMap.get(key);
	}

	public void setMapResultMap(Map<String, ResultMap> mapResultMap) {
		this.mapResultMap = mapResultMap;
	}
	
	public void addResultMap(String key, ResultMap resultMap) {
		this.mapResultMap.put(key, resultMap);
	}

	public List<Interceptor> getInterceptors() {
		return interceptors;
	}

	public void setInterceptors(List<Interceptor> interceptors) {
		this.interceptors = interceptors;
	}
	
	public void addInterceptor(Interceptor interceptor) {
		this.interceptors.add(interceptor);
	}

	public Map<String, Object> getMapperProxyMap() {
		return mapperProxyMap;
	}

	public void setMapperProxyMap(Map<String, Object> mapperProxyMap) {
		this.mapperProxyMap = mapperProxyMap;
	}
	
	public void addMapperProxy(String key, Object proxy) {
		this.mapperProxyMap.put(key, proxy);
	}
	
	public Object getMapperProxy(String key) {
		return this.mapperProxyMap.get(key);
	}

	@Override
	public String toString() {
		return "Configuration [dataSource=" + dataSource + ", sqlMap=" + sqlMap + ", mapResultMap=" + mapResultMap;
	}
	
}
